﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LaughingDog.GameObjects;
using Microsoft.Xna.Framework;

namespace LaughingDog.Components
{
    /// <summary>
    /// A force applied constantly to a RigidBody.
    /// </summary>
    public class ConstantForce : Behaviour
    {
        private Vector2 mForce = Vector2.Zero;
        private Single mTorque = 0.0f;

        /// <summary>
        /// The amount of force to apply every frame.
        /// </summary>
        public Vector2 Force { get { return mForce; } set { mForce = value; } }

        /// <summary>
        /// The amount of torque to apply every frame.
        /// </summary>
        public Single Torque { get { return mTorque; } set { mTorque = value; } }

        public ConstantForce(GameObject gameObject)
            : base(gameObject)
        {
            
        }

        /// <summary>
        /// Updates this ConstantForce.
        /// </summary>
        public override void Update()
        {            
            if (GameObject.RigidBody != null)
            {
                GameObject.RigidBody.ApplyForce(mForce);
                GameObject.RigidBody.ApplyTorque(mTorque);
            }

            base.Update();
        }
    }
}
